<template>
  <div class="package-template-container">
    <el-row :gutter="20">
      <!-- 固定卡片 -->
      <el-col :span="6">
        <div class="card vertical-card">
          <div class="card-img-wrapper">
            <div class="left-card">
              <div class="title">包装定制</div>
              <div class="desc">定制自己的专属包装形象</div>
            </div>
          </div>
          <div class="card-desc-wrapper">
            <div class="card-desc-content">
              <el-button class="custom-btn" round plain @click="handleCustomClick">
                一键定制 <el-icon style="margin-left:4px"><ArrowRight /></el-icon>
              </el-button>
            </div>
          </div>
        </div>
      </el-col>
      <!-- 动态卡片 -->
      <el-col
          v-for="item in contentList"
          :key="item.id"
          :span="6"
      >
        <div class="card vertical-card">
          <div class="card-img-wrapper">
            <img :src="item.url" class="card-vertical-img" />
          </div>
          <el-tooltip :content="item.name" placement="top" effect="dark">
            <div class="card-desc-wrapper">
              <div class="card-desc-content">
                <span class="card-desc-text">{{ item.name }}</span>
              </div>
            </div>
          </el-tooltip>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue'
import axiosUtil from '../../axios-util/axios-util'
import { ArrowRight } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import utils from '../../utils/utils';

//主题控制light  dark
const theme = utils.getTheme();
const contentList = ref([])

onMounted(() => {
  initContentList()
})

const initContentList = async () => {
  const response = await axiosUtil.post('api/digitalpeople/packinglist', {
    profile_id:''
  })
  if (response.data.code === 1 && response.data.data) {
    contentList.value = response.data.data
  }
}

const handleGenerateVideo = (item: any) => {
  // 处理生成视频的点击事件
  console.log('生成视频', item)
}

const handleCustomClick = () => {
  ElMessage({
    message: '请联系管理员定制',
    type: 'info',
    duration: 2000
  })
}
</script>

<style scoped>
.package-template-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
}

.package-template-container::-webkit-scrollbar {
  width: 6px;
}

.package-template-container::-webkit-scrollbar-thumb {
  background: v-bind('theme === "light" ? "linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.2))" : "linear-gradient(180deg, rgba(0, 255, 255, 0.2), rgba(0, 255, 255, 0.4), rgba(0, 255, 255, 0.2))"');
  border-radius: 3px;
  border: 1px solid v-bind('theme === "light" ? "rgba(0, 0, 0, 0.3)" : "rgba(0, 255, 255, 0.3)"');
  box-shadow: 0 0 10px v-bind('theme === "light" ? "rgba(0, 0, 0, 0.2)" : "rgba(0, 255, 255, 0.2)"');
}

.package-template-container::-webkit-scrollbar-track {
  background: v-bind('theme === "light" ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 20, 40, 0.2)"');
  border-radius: 3px;
  border: 1px solid v-bind('theme === "light" ? "rgba(0, 0, 0, 0.1)" : "rgba(0, 255, 255, 0.1)"');
}

.card {
  height: 320px;
  display: flex;
  flex-direction: column;
  padding: 12px;
  box-sizing: border-box;
}

.vertical-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 320px;
  background: v-bind('theme === "light" ? "rgba(255, 255, 255, 0.1)" : "rgba(255, 255, 255, 0.1)"');
  border: 1px solid v-bind('theme === "light" ? "rgba(255, 255, 255, 0.2)" : "rgba(255, 255, 255, 0.2)"');
  border-radius: 10px;
  box-shadow: 0 0 10px v-bind('theme === "light" ? "rgba(0, 0, 0, 0.1)" : "rgba(0, 0, 0, 0.2)"');
  transition: all 0.3s ease;
  overflow: hidden;
  margin-bottom: 24px;
}

.vertical-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px v-bind('theme === "light" ? "rgba(0, 0, 0, 0.15)" : "rgba(0, 255, 255, 0.15)"');
  border-color: v-bind('theme === "light" ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 255, 255, 0.3)"');
}

.card-img-wrapper {
  flex: 0 0 75%;
  height: 75%;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  /* background: v-bind('theme === "light" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.3)"'); */
  position: relative;
}

.card-vertical-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px 8px 0 0;
  /* border-bottom: 1px solid v-bind('theme === "light" ? "rgba(0, 0, 0, 0.08)" : "rgba(0, 255, 255, 0.08)"'); */
}

.card-desc-wrapper {
  margin-top: 10px;
  flex: 0 0 15%;
  height: 15%;
  padding: 8px 14px;
  background-color: transparent;
  /* background: v-bind('theme === "light" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.2)"'); */
  color: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"');
  font-size: 1em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  position: relative;
}

.card-desc-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.card-desc-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.2s;
  margin-right: 8px;
  color: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"');
}

.card-bottom-bar {
  flex: 0 0 10%;
  height: 10%;
  padding: 0 14px 8px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  font-size: 0.85em;
  color: #fff;
}

.card-time {
  color: #fff;
  font-size: 0.85em;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.left-card {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  height: 100%;
  padding: 20px;
  background-color: transparent;
  /* background: v-bind('theme === "light" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.3)"'); */
  border-radius: 10px;
}

.title {
  font-size: 28px;
  font-weight: bold;
  color: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"');
  margin-bottom: 18px;
  line-height: 1.2;
}

.desc {
  font-size: 14px;
  color: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"');
  margin-bottom: 32px;
  line-height: 1.5;
}

.custom-btn {
  border: 2px solid v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"') !important;
  color: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"') !important;
  background: transparent !important;
  font-size: 16px;
  font-weight: bold;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  letter-spacing: 2px;
}

.custom-btn:hover {
  background: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.05)" : "rgba(255, 255, 255, 0.05)"') !important;
  color: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"') !important;
  border-color: v-bind('theme === "light" ? "rgba(0, 0, 0, 0.8)" : "#fff"') !important;
}

.avatar {
  width: 100%;
  height: 100%;
  max-width: 160px;
  max-height: 200px;
  border-radius: 10px;
  object-fit: cover;
}

.name {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
}

.voice-name, .packing-name {
  font-size: 14px;
  color: #fff;
}

.card-bottom {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  font-size: 12px;
  color: #fff;
}

@media (max-width: 1200px) {
  .vertical-card {
    height: 280px;
  }
}

@media (max-width: 768px) {
  .vertical-card {
    height: 220px;
  }
}
</style>
